/*
 * 
 * Copyright 2011 visual-analysis-of-cancer.
 * This file is part of visual-analysis-of-cancer.
 * 
 * visual-analysis-of-cancer is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * visual-analysis-of-cancer is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with kOSMik.  If not, see <http://www.gnu.org/licenses/>.
 *  
 * visual-analysis-of-cancer:
 * An tool to analye the WHO and GLOBOCAN cancer data.
 * http://code.google.com/p/visual-analysis-of-cancer/
 * 
 * 
 * 
 * Authors: Erik Sniegula, Johannes Dahlke
 * 
 * Module:  Programming in Processing for Visual Analytics
 * Group:   20
 * 
 * Created: Aug. 2011
 * Version: 1.0
 *
 */
 




package de.fuberlin.processing.who.cancer.gui.healthgraph;

import processing.core.PVector;


public class Rect {

	private PVector position;
	private float width;
	private float height;
	
	
	public Rect( PVector position, float width, float height) {
		this.position = new PVector( position.x, position.y, position.z);
		this.width = width;
		this.height = height;
	}
	
	public Rect( float x, float y, float width, float height) {
		this.position = new PVector( x, y);
		this.width = width;
		this.height = height;
	}

	public Rect( float x, float y, float z, float width, float height) {
		this.position = new PVector( x, y, z);
		this.width = width;
		this.height = height;
	}
	
	public Rect() {
		this.position = new PVector();
		this.width = 0;
		this.height = 0;
	}
	
	public Rect( Rect r) {
		this.position = new PVector( r.position.x, r.position.y, r.position.z);
		this.width = r.width;
		this.height = r.height;
	}
	
	
	@Override
	public boolean equals( Object obj) {
		if (obj instanceof Rect) {
			Rect r = (Rect) obj;
			return this.position.equals( r.position) && this.width == r.width && this.height == r.height;
		} 
		return false;
	}
	
	
	public float getLeft() {
		return position.x;
	}
	
	public void setLeft( float left) {
		position.x = left;
	}
	
	public float getTop() {
		return position.y;
	}
	
	public void setTop( float top) {
		position.y = top;
	}

	public float getWidth() {
		return width;
	}
	
	public void setWidth( float width) {
		this.width = width;
	}
	
	public float getHeight() {
		return height;
	}
	
	public void setHeight( float height) {
		this.height = height;
	}

	public float getRight() {
		return position.x +width;
	}
	
	public void setRight( float right) {
		 width = right -position.x;
	}
	
	public float getBottom() {
		return position.y +height;
	}
	
	public void setBottom( float bottom) {
		 height = bottom -position.y;
	}
	
	@Override
	public String toString() {
		return String.format( "x:%.1f\ty:%.1f\tz:%.1f\tw:%.1f\th:%.1f\tr:%.1f\tb:%.1f", position.x, position.y, position.z, width, height, getRight(), getBottom());
	}
	
	
}
